//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef WATERTEK_TP_DRIVER_H
#define WATERTEK_TP_DRIVER_H

#include "SMA_types.h"
/* 
serial port parameters. Note that TP_BPS (clock frequency of
the SSPCLK pin for accessing the touchscreen controller) influences 
the sampling interval. Slower clocks yield higher accuracy (with
diminishing returns. Faster clocks shorten the measurement
interval and consume less power.
*/
#define TP_WORDSIZE 13
#define TP_BPS 100000

/* control byte */
#define TP_START _BIT(7)
#define TP_SINGLE_END  _BIT(2)
#define TP_DIFFERENTIAL 0
#define TP_MEASURE_X _SBF(4,1)
#define TP_MEASURE_Y _SBF(4,5)
#define TP_MEASURE_IN3 _SBF(4,2)
#define TP_MEASURE_IN4 _SBF(4,6)
#define TP_POWER_DOWN_PEN_IRQ 0
#define TP_POWER_DOWN 1
#define TP_POWER_RESERVED 2
#define TP_POWER_ON 3

/* pen state */
#define TP_PEN_DOWN     1
#define TP_PEN_UP       0

/* Calibrate cross position */
#define CAL_X1 10
#define CAL_Y1 10
#define CAL_X2 230
#define CAL_Y2 310

void TP_Init( void );
void TP_Calibrate( void );
UNS_8 TP_GetPos( UNS_32 *x, UNS_32 *y );
UNS_8 TP_SampleTouchScreen(UNS_32 *x, UNS_32 *y);

#endif /* WATERTEK_TP_DRIVER_H */
